/*
通过api封装
测试地址/正式地址

*/
import axios from './http.js';
import QS from 'qs'
const debug = true;
let HOST, IMG_HOST;
if (debug) {
    HOST = 'https://test1.instore.cn/';
    IMG_HOST = 'https://test1.instore.cn/'
} else {
    HOST = 'https://down.tanxiaji.com/';
    IMG_HOST = 'https://test1.instore.cn/'
}
import {showFullScreenLoading,hideFullScreenLoading} from '@/untils/Loading.js'
export function get(url, params){
    showFullScreenLoading();    
    return new Promise((resolve, reject) =>{        
        axios.get('/api'+url, {
            params: params        
        })        
        .then(res => {            
            resolve(res.data);   
            hideFullScreenLoading();    
        })        
        .catch(err => {            
            reject(err.data)
            hideFullScreenLoading();    
        })    
    });
}

export function post(url, params) {  
    showFullScreenLoading();    
    return new Promise((resolve, reject) => {         
        axios.post('/api'+url, QS.stringify(params))        
        .then(res => {            
            resolve(res.data); 
            hideFullScreenLoading();         
        })        
        .catch(err => {            
            reject(err.data);  
            hideFullScreenLoading();     
        })    
    });
}

export default {get, post ,HOST,IMG_HOST}